//
//  WHCollectionViewCell.m
//  GroupFourFM
//
//  Created by dllo on 15/12/22.
//  Copyright © 2015年 GroupFour. All rights reserved.
//

#import "WHCollectionViewCell.h"
#import <UIImageView+WebCache.h>


@implementation WHCollectionViewCell



-(instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    
    if (self){
        
        [self createSubs];
        
    }
    return self;
}

-(void)createSubs{
    
    self.coverPathImageView = [[UIImageView alloc] init];
    //self.coverPathImageView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.coverPathImageView];
#pragma mark - 添加约束
    
    [self.coverPathImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(@5);
        make.top.mas_equalTo(@5);
        make.width.mas_equalTo(@20);
        make.height.mas_equalTo(@25);
        
    }];
    
    self.classTitleLabel = [[UILabel alloc] init];
    //self.classTitleLabel.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.classTitleLabel];
    
    [self.classTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.coverPathImageView.mas_right).offset(10);
        make.top.height.equalTo(self.coverPathImageView);
        make.right.mas_equalTo(@-10);
        
    }];
    
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = [UIColor lightGrayColor];
    lineView.alpha = 0.3;
    [self.contentView addSubview:lineView];
    
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(@-10);
        make.top.equalTo(self.contentView.mas_bottom).offset(0);
        make.right.mas_equalTo(@10);
        make.height.mas_equalTo(@1);
    }];
    
    self.shortLineView = [[UIView alloc] init];
    _shortLineView.backgroundColor = [UIColor lightGrayColor];
    _shortLineView.alpha = 0.3;
    [self.contentView addSubview:self.shortLineView];
    
    [self.shortLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.contentView.mas_right).offset(10);
        make.top.equalTo(self.coverPathImageView);
        make.width.mas_equalTo(@1);
        make.height.mas_equalTo(@20);
        
    }];
    
}



-(void)setClassList:(WSModel *)classList{
    
    if (_classList != classList) {
        
        _classList = classList;
    }
    [self.coverPathImageView sd_setImageWithURL:[NSURL URLWithString:self.classList.coverPath] placeholderImage:nil];
    self.classTitleLabel.text = self.classList.title;
    
    
}

@end
